/**
 * ClaimExamService.java
 * Version 1.0.0
 * Created on 2018年7月24日
 *
 */
package com.yincheng.oes.business.exam.examlist.claimexam;

import java.util.HashMap;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yincheng.oes.business.exam.judgepaper.mapper.PaperResultMapper;
import com.yincheng.oes.sso.util.UserUtils;

/**
 * @author yangsy
 * @version 1.0.0
 * @since
 * 创建时间：2018年7月24日
 * <p>
 * 功能描述：认领试卷
 * <p>
 * 邮箱地址：446948434@qq.com
 */
@Service
public class ClaimExamService {

    @Autowired
    private PaperResultMapper paperResultMapper;

    public void claimExamsByResultId(String resultIds) {
        String[] split = StringUtils.split(StringUtils.defaultIfBlank(resultIds, ""), ",");
        String teacherUid = UserUtils.getUser().getUserId();
        String teacherName = UserUtils.getUser().getUserName();
        for (String resultId : split) {
            HashMap<String, String> map = new HashMap<String, String>();
            map.put("resultId", resultId);
            map.put("teacherUid", teacherUid);
            map.put("teacherName", teacherName);
            paperResultMapper.updateByParam(map);
        }
    }
}
